/*
<Copyright (C) 2011 Dru Moore>

This file is part of demorecorder.

vlc-remote is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

demorecorder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with demorecorder.  If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import com.meego 1.0
import "common"

Page {
    id: mixerPage
    tools: commonTools

    property int trackCount:  trackListModel.count

    Component.onCompleted: {
        screen.allowedOrientations = Screen.Portrait;
        orientationLock = Screen.Portrait;
    }

    Component {
        id: tracksListHighlight

        Rectangle {
            color: "#ffffff"
            border.width: 2
            border.color: "#ffffff"
            radius:  8
            opacity: 0.10
            visible: (tracksListView &&  -1 < tracksListView.currentIndex)
            y: (tracksListView && -1 < tracksListView.currentIndex) ? tracksListView.currentItem.y - 2 : 0
        }
    }

    ScrollDecoratorStyle {
        id: scrollDecoratorStyle
        inverted: true
    }

    ScrollDecorator {
        flickableItem: tracksListView
        platformStyle: scrollDecoratorStyle
        //z: 12
    }


    ListView {
        id: tracksListView
        height: 490
        width: parent.width
        anchors.bottom: buttonBar.top
        model: trackListModel
        spacing: 2
        delegate: TrackDelegate {
            name:  title
            muted: isMuted
            iconType: icon
            textColor: color
            active: isActive
            onClicked: {
                tracksListView.currentIndex = index;
            }
            onMuteChanged: {
                demoRecorderObject.trackToggleMute(index, muted);
            }
            onActiveChanged: {
                console.debug(active + " activeToggled");
                demoRecorderObject.trackToggleActive(index, active);
            }
            onDeleteClicked: {
                console.debug(index + " delete requested");
            }
            onNameUpdated: {
                console.debug(index + " name changed " + newName);
            }
        }
        highlight: tracksListHighlight
        highlightFollowsCurrentItem: true
        highlightMoveDuration: 0
        clip: true
    }

    Rectangle {
        id: buttonBar
        color: "black"
        width: parent.width
        anchors.bottom: parent.bottom
        height: 80

        Row {
            id: buttons
            anchors.verticalCenter: parent.verticalCenter
            spacing: 16

            Button {
                id: editDetailsButton
                text: "Edit d"
                width:  120
            }
            Button {
                id: editTrackButton
                text: "Edit t"
                width:  120
            }
        }

    }

}
